package com.cskaoyan;

import com.cskaoyan.utils.JDBCUtils;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 * 创建日期: 2021/11/23 14:40
 *
 * @author ciggar
 * 使用工具类
 */
public class JDBCDemo7 {

    public static void main(String[] args) throws SQLException {

        // 获取连接
        Connection connection = JDBCUtils.getConnection();

        // 获取statement对象
        Statement statement = connection.createStatement();

        // 执行SQL语句
        ResultSet resultSet = statement.executeQuery("select * from user1 where uid = 2");

        // 解析结果集
        while (resultSet.next()) {

            String name = resultSet.getString("name");

            System.out.println("name:" + name);

        }

        // 关闭资源
        JDBCUtils.closeReources(resultSet,statement,connection);

    }
}
